Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		Super.OnCreate()
				
		DISPLAY.SetVirtualSize(320,480)
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		Return 0
	End

End


Class TTmpScreen Extends TScreen
	
	Field spr:TSprite
	Field accel:TVector2 = New TVector2(0,0)
	Field angle:Float = 0
	
	Field AccX:Float 
	Field AccY:Float 	
	Field AccZ:Float 
	
	' START when app is created
	Method Start:Void()
		IMAGES.Load("bg.png","BG")
		Self.spr = New TSprite("TEST",IMAGES.Find("BG"),160,240	)	
	End
	
	' main app logic loop update
	Method Update:Void()
		Self.spr.Update()
		Self.AccX = AccelX()
		Self.AccY = AccelY()
		Self.AccZ = AccelZ()
		
		Self.accel.Set(Self.AccX,Self.AccY)
		
		Self.spr.LookAt(160+Self.AccX*32,240+Self.AccY*32,True)
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		Self.spr.Draw()
		
		DrawText("Ax : "+Self.AccX,10,10)
		DrawText("Ay : "+Self.AccY,10,25)
		DrawText("Az : "+Self.AccZ,10,40)
		'DrawText("Ang: "+Self.spr.rotation,10,55)
		
		SetColor(255,0,0)
		DrawLine(160,240,160+Self.accel.x*32,240+Self.accel.y*32)
		SetColor(0,255,0)
		DrawLine(160,240,160+Self.AccY*32,240+Self.AccZ*32)
		SetColor(0,0,255)
		DrawLine(160,240,160+Self.AccX*32,240+Self.AccZ*32)
	End
End
